package org.dandsoft.blackbox.knowledge;

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * User: dvilyuzhanin
 * Date: 13.01.2009 19:57:02
 */
public abstract class AbstractInfo<T extends AbstractInfo> {

    private String groupName;
    private String type;
    private DataFormat format;
    private InfoName name;


    public AbstractInfo(String groupName, String type, DataFormat format) {
        if (type == null || type.length() == 0) {
            throw new IllegalArgumentException("Type can not be null or empty");
        }

        if (format == null) {
            throw new IllegalArgumentException("Data format can not be null");
        }
        this.groupName = groupName;
        this.type = type;
        this.format = format;
    }

    public abstract void store(OutputStream out) throws IOException;

    public abstract void load(InputStream in) throws IOException;

    public String getGroupName() {
        return groupName;
    }

    public String getType() {
        return type;
    }

    public DataFormat getFormat() {
        return format;
    }

    public InfoName getName() {
        return name;
    }

    public void setName(InfoName name) {
        this.name = name;
    }


    public String toString() {
        return "AbstractInfo{" +
               "groupName='" + groupName + '\'' +
               ", type=" + type +
               ", name=" + name +
               '}';
    }
}
